package org.truenewx.tnxjee.core.util;

import java.util.*;

public class TreeProperties extends Properties {

    @Override
    public Enumeration<Object> keys() {
        return Collections.enumeration(keySet());
    }

    @Override
    public Set<Object> keySet() {
        return new TreeSet<>(super.keySet());
    }

    @Override
    public Set<Map.Entry<Object, Object>> entrySet() {
        TreeSet<Map.Entry<Object, Object>> set = new TreeSet<>((e1, e2) -> {
            String k1 = String.valueOf(e1.getKey());
            String k2 = String.valueOf(e2.getKey());
            return k1.compareTo(k2);
        });
        set.addAll(super.entrySet());
        return set;
    }

}
